package com.ruoyi.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.AssetHouse;
import com.ruoyi.project.service.IAssetHouseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房产资产信息Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/project/houseResource")
public class AssetHouseController extends BaseController
{
    @Autowired
    private IAssetHouseService assetHouseService;

    /**
     * 查询房产资产信息列表
     */
    @PreAuthorize("@ss.hasPermi('project:houseResource:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssetHouse assetHouse)
    {
        startPage();
        List<AssetHouse> list = assetHouseService.selectAssetHouseList(assetHouse);
        return getDataTable(list);
    }

    /**
     * 导出房产资产信息列表
     */
    @PreAuthorize("@ss.hasPermi('project:houseResource:export')")
    @Log(title = "房产资产信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssetHouse assetHouse)
    {
        List<AssetHouse> list = assetHouseService.selectAssetHouseList(assetHouse);
        ExcelUtil<AssetHouse> util = new ExcelUtil<AssetHouse>(AssetHouse.class);
        util.exportExcel(response, list, "房产资产信息数据");
    }

    /**
     * 获取房产资产信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:houseResource:query')")
    @GetMapping(value = "/{houseId}")
    public AjaxResult getInfo(@PathVariable("houseId") Long houseId)
    {
        return success(assetHouseService.selectAssetHouseByHouseId(houseId));
    }

    /**
     * 新增房产资产信息
     */
    @PreAuthorize("@ss.hasPermi('project:houseResource:add')")
    @Log(title = "房产资产信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssetHouse assetHouse)
    {
        return toAjax(assetHouseService.insertAssetHouse(assetHouse));
    }

    /**
     * 修改房产资产信息
     */
    @PreAuthorize("@ss.hasPermi('project:houseResource:edit')")
    @Log(title = "房产资产信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssetHouse assetHouse)
    {
        return toAjax(assetHouseService.updateAssetHouse(assetHouse));
    }

    /**
     * 删除房产资产信息
     */
    @PreAuthorize("@ss.hasPermi('project:houseResource:remove')")
    @Log(title = "房产资产信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{houseIds}")
    public AjaxResult remove(@PathVariable Long[] houseIds)
    {
        return toAjax(assetHouseService.deleteAssetHouseByHouseIds(houseIds));
    }
}
